#include "KIT.h"
using namespace std;
using namespace cv;

KIT::KIT(TiXmlElement* frameNode)
{
    //ctor
    m_id=atoi(frameNode->Attribute("number"));
    m_path=frameNode->Attribute("file");
    m_time=frameNode->Attribute("utc");
    m_cellsize=atof(frameNode->Attribute("pixel_size"));
    m_pos=cv::Point_<float>(atof(frameNode->Attribute("x")),atof(frameNode->Attribute("y")));
    TiXmlElement* objectlist=frameNode->FirstChildElement("objectlist");
    TiXmlElement* child=objectlist->FirstChildElement();
    while(child)
    {
        //Car temp(child);
        m_cars.push_back(Car(child));
        child=child->NextSiblingElement();
    }
}

KIT::~KIT()
{
    //dtor
}

const string KIT::printKit()
{
    string Result;
    stringstream id;
    id<<m_id;
    Result+="FrameID: "+id.str()+"\t"+m_path+"\n";//+" CarNum: "+m_cars.size()+"\n";
    vector<Car>::iterator it=m_cars.begin();
    for(; it!=m_cars.end(); ++it)
    {
        Result+="\t"+it->printCar()+"\n";
    }
    return Result;
}
